"""
KPL股票数据模型定义
"""
from sqlalchemy import String, Float, DateTime
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import Base, BaseModelMixin
from datetime import datetime


class KPLStock(Base, BaseModelMixin):
    """
    KPL股票数据模型
    对应接口返回的股票数据结构
    """
    __tablename__ = "kpl_stocks"
    
    # 股票代码
    stock_code: Mapped[str] = mapped_column(String(20), index=True)
    # 股票名称
    stock_name: Mapped[str] = mapped_column(String(50))
    # 涨幅
    change_percent: Mapped[float] = mapped_column(Float, default=0.0)
    # 涨停原因
    change_reason: Mapped[str] = mapped_column(String(200), default="")
    # 封板资金
    limit_up_amount: Mapped[float] = mapped_column(Float, default=0.0)
    # 流通市值
    circulation_market_value: Mapped[float] = mapped_column(Float, default=0.0)
    # 入选理由
    selection_reason: Mapped[str] = mapped_column(String(200), default="")
    # 成交额
    turnover_amount: Mapped[float] = mapped_column(Float, default=0.0)
    # 成交量
    volume: Mapped[float] = mapped_column(Float, default=0.0)
    # 换手率
    turnover_rate: Mapped[float] = mapped_column(Float, default=0.0)
    # 所属行业
    industry: Mapped[str] = mapped_column(String(50), default="")
    # 数据日期
    data_date: Mapped[datetime] = mapped_column(DateTime)